package edu.cuit.campus.po;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import edu.cuit.campus.enums.Job;
import edu.cuit.campus.validation.ValidationGroup1;
import edu.cuit.campus.validation.ValidationGroup2;
import edu.cuit.campus.web.converter.JobDeserializer;
import jakarta.validation.constraints.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/8/15 15:09
 */
@Setter
@Getter
public class Employee {
    private Integer id;

    @NotBlank(message = "{not-blank-employee-username}",groups = ValidationGroup1.class)
    @Size(min = 4, max = 12, message = "{size-employee-username}", groups = ValidationGroup1.class)
    private String username;

    @NotBlank(message = "{not-blank-employee-password}",groups = ValidationGroup1.class)
    private String password;

    @NotNull(message = "{not-blank-employee-email}",groups = ValidationGroup1.class)
    @Email(message = "{email-employee-email}",groups = ValidationGroup1.class)
    private String email;

    @Pattern(regexp = "^1[358]\\d{9}$", message = "{pattern-employee-phone}",groups = ValidationGroup2.class)
    private String phone;

    @Past(message = "{past-employee-born-date}", groups = {ValidationGroup1.class, ValidationGroup2.class})
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate bornDate;

    @FutureOrPresent(message = "{future-employee-hire-date}", groups = {ValidationGroup1.class, ValidationGroup2.class})
    private LocalDate hireDate;

    //@Min(value = 2000, message = "{min-employee-salary}",groups = {ValidationGroup1.class, ValidationGroup2.class})
    @Max(value = 50000, message = "{max-employee-salary}", groups = {ValidationGroup1.class, ValidationGroup2.class})
    private int salary;


    @JsonDeserialize(using = JobDeserializer.class)
    private Job job = Job.CLERK;

    @Size(max = 200, message = "{size-employee-intro}", groups = {ValidationGroup1.class, ValidationGroup2.class})
    private String intro;
}
